<?php

namespace app\common\model;

use think\Model;

class Course extends Base
{
    // 定义时间戳字段名
    protected $createTime = 'create_time';
    protected $updateTime = 'update_time';

    /**
     * expireTypeList
     * @var array[]
     */
    public static $expireTypeList = [
        ['id' => 1, 'name' => '秒'],
        ['id' => 2, 'name' => '分'],
        ['id' => 3, 'name' => '时'],
        ['id' => 4, 'name' => '天'],
        ['id' => 5, 'name' => '月'],
        ['id' => 6, 'name' => '年'],
    ];



    /**
     * allTypeSelectList
     * @var array[]
     */
    public static $allTypeSelectList = [
        ['id' => 0, 'name' => '请选择'],
        ['id' => 1, 'name' => '必考'],
        ['id' => 2, 'name' => '选考'],
        ['id' => 3, 'name' => '加考'],
    ];

    /**
     * getInfo
     * @param $id
     * @param string $field
     * @return Profession|array|Model|null
     * @throws
     */
    public function getInfo($id, $field = '')
    {
        $where = ['id' => $id];
        return $this->where($where)->field($field)->find();
    }


    
    /**
     * getExpireTypeName
     * @param $type
     * @return string
     */
    public function getExpireTypeName($type)
    {
        foreach (self::$expireTypeList as $item) {
            if ($item['id'] == $type) {
                return $item['name'];
            }
        }
        return '未知';
    }
}